package cn.stylefeng.guns.modular.yingbao.controller;

import cn.stylefeng.guns.base.pojo.page.LayuiPageInfo;
import cn.stylefeng.guns.modular.yingbao.entity.AboutUs;
import cn.stylefeng.guns.modular.yingbao.model.params.AboutUsParam;
import cn.stylefeng.guns.modular.yingbao.service.AboutUsService;
import cn.stylefeng.roses.core.base.controller.BaseController;
import cn.stylefeng.roses.core.reqres.response.ResponseData;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;


/**
 * 关于模块控制器
 *
 * @author zs
 * @Date 2019-12-11 18:11:46
 */
@CrossOrigin
@Api(tags = "关于我们模块")
@Controller
@RequestMapping("/aboutUs")
public class AboutUsController extends BaseController {

    private String PREFIX = "/aboutUs";

    @Autowired
    private AboutUsService aboutUsService;

    /**
     * 跳转到主页面
     *
     * @author zs
     * @Date 2019-12-11
     */
    @RequestMapping("")
    public String index() {
        return PREFIX + "/aboutUs.html";
    }

    /**
     * 新增页面
     *
     * @author zs
     * @Date 2019-12-11
     */
    @RequestMapping("/add")
    public String add() {
        return PREFIX + "/aboutUs_add.html";
    }

    /**
     * 编辑页面
     *
     * @author zs
     * @Date 2019-12-11
     */
    @RequestMapping("/edit")
    public String edit() {
        return PREFIX + "/aboutUs_edit.html";
    }

    /**
     * 新增接口
     *
     * @author zs
     * @Date 2019-12-11
     */
    @RequestMapping("/addItem")
    @ResponseBody
    public ResponseData addItem(AboutUsParam aboutUsParam) {
        this.aboutUsService.add(aboutUsParam);
        return ResponseData.success();
    }

    /**
     * 编辑接口
     *
     * @author zs
     * @Date 2019-12-11
     */
    @RequestMapping("/editItem")
    @ResponseBody
    public ResponseData editItem(AboutUsParam aboutUsParam) {
        this.aboutUsService.update(aboutUsParam);
        return ResponseData.success();
    }

    /**
     * 删除接口
     *
     * @author zs
     * @Date 2019-12-11
     */
    @RequestMapping("/delete")
    @ResponseBody
    public ResponseData delete(AboutUsParam aboutUsParam) {
        this.aboutUsService.delete(aboutUsParam);
        return ResponseData.success();
    }

    /**
     * 查看详情接口
     *
     * @author zs
     * @Date 2019-12-11
     */
    @RequestMapping("/detail")
    @ResponseBody
    public ResponseData detail(AboutUsParam aboutUsParam) {
        AboutUs detail = this.aboutUsService.getById(aboutUsParam.getId());
        return ResponseData.success(detail);
    }

    /**
     * 查询列表
     *
     * @author zs
     * @Date 2019-12-11
     */
    @ResponseBody
    @RequestMapping("/list")
    public LayuiPageInfo list(AboutUsParam aboutUsParam) {
        return this.aboutUsService.findPageBySpec(aboutUsParam);
    }

    @GetMapping("queryAll")
    @ResponseBody
    @ApiOperation("查看所有关于我们")
    public ResponseData queryAll(){
        return aboutUsService.queryAll();
    }

}


